$(function () {
    /**初始化信息验证的**/
    var icon = "<i class='zmdi zmdi-close-circle zmdi-hc-fw'></i> ";
    $("#job-add-form").validate({
        rules: {
            beanName: {
                required: true,
                maxlength: 100
            },
            methodName: {
                required: true,
                maxlength: 100
            },
            cronExpression: {
                required: true,
                maxlength: 100,
                remote: {
                    url: "job/checkCron",
                    type: "get",
                    dataType: "json",
                    data: {
                        cron: function () {
                            return $("#cronExpression").val().trim();
                        }
                    }
                }
            }
        },
        messages: {
            beanName: {
                required: icon + "请输入Bean名称",
                maxlength: icon + "长度不能超过100个字符"
            },
            methodName: {
                required: icon + "请输入方法名称",
                maxlength: icon + "长度不能超过100个字符"
            },
            cronExpression: {
                required: icon + "请输入cron表达式",
                maxlength: icon + "长度不能超过100个字符",
                remote: icon + "cron表达式不合法"
            }
        }
    });
});
/**保存**/
function saveJobInfo(){
    const  $jobAddForm =$("#job-add-form");
    validator = $jobAddForm.validate();
    var flag = validator.form();
    if (flag) {
        $.post(ctx + "job/add", $jobAddForm.serialize(), function (r) {
            if (r.code === 0) {
                refresh();
                $("#job_info").modal("hide");
                $JuXue.n_success(r.msg);
            } else $JuXue.n_danger(r.msg);
        });
    }else{
        $JuXue.n_warning("请填写完整信息");
    }
}